/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import junit.framework.TestCase;
import junit.framework.Assert;



/**
 * Performs Validation Test for url validations.
 *
 * @version $Revision: 1128446 $ $Date: 2011-05-27 13:29:27 -0700 (Fri, 27 May 2011) $
 */
public class UrlValidatorTest extends TestCase {

   private boolean printStatus = false;
   private boolean printIndex = false;//print index that indicates current scheme,host,port,path, query test were using.

   public UrlValidatorTest(String testName) {
      super(testName);
   }

   
   
   public void testManualTest()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   System.out.println(urlVal.isValid("http://www.amazon.com"));
	   System.out.println(urlVal.isValid("http:/www.amazon.com"));
	   System.out.println(urlVal.isValid("http://www.amazon.com/dp/B00JG8GOWU/ref=sd_allcat_k_kdppnwf"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:8080"));
	   System.out.println(urlVal.isValid("http://localhost"));
	   System.out.println(urlVal.isValid("ftp://www.amazon.com"));
	   System.out.println(urlVal.isValid("http://192.25.67.91"));
	   System.out.println(urlVal.isValid("http://256.10.25.18"));
	   
   }
   
   
   public void testYourFirstPartition()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   System.out.println(urlVal.isValid("http://www.amazon.com"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:-99"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:-1"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:0"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:1"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:9"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:10"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:99"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:100"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:999"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:1000"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:9999"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:10000"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:65535"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:65536"));
	   System.out.println(urlVal.isValid("http://www.amazon.com:a564"));
   }
   
   public void testYourSecondPartition(){
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   System.out.println(urlVal.isValid("http://0"));
	   System.out.println(urlVal.isValid("http://0.0"));
	   System.out.println(urlVal.isValid("http://0.0.0"));
	   System.out.println(urlVal.isValid("http://0.0.0.0"));
	   System.out.println(urlVal.isValid("http://0.0.0.0.0"));
	   System.out.println(urlVal.isValid("http://0.0.0.1"));
	   System.out.println(urlVal.isValid("http://1.1.1.1"));
	   System.out.println(urlVal.isValid("http://10.1.1.1"));
	   System.out.println(urlVal.isValid("http://100.1.1.1"));
	   System.out.println(urlVal.isValid("http://255.1.1.1"));
	   System.out.println(urlVal.isValid("http://256.1.1.1"));
	   System.out.println(urlVal.isValid("http://999.1.1.1"));
	   System.out.println(urlVal.isValid("http://1000.1.1.1"));
	   System.out.println(urlVal.isValid("http://1.10.1.1"));
	   System.out.println(urlVal.isValid("http://1.100.1.1"));
	   System.out.println(urlVal.isValid("http://1.255.1.1"));
	   System.out.println(urlVal.isValid("http://1.256.1.1"));
	   System.out.println(urlVal.isValid("http://1.999.1.1"));
	   System.out.println(urlVal.isValid("http://1.1000.1.1"));
	   System.out.println(urlVal.isValid("http://1.1.10.1"));
	   System.out.println(urlVal.isValid("http://1.1.100.1"));
	   System.out.println(urlVal.isValid("http://1.1.255.1"));
	   System.out.println(urlVal.isValid("http://1.1.256.1"));
	   System.out.println(urlVal.isValid("http://1.1.999.1"));
	   System.out.println(urlVal.isValid("http://1.1.1000.1"));
	   System.out.println(urlVal.isValid("http://1.1.1.10"));
	   System.out.println(urlVal.isValid("http://1.1.1.100"));
	   System.out.println(urlVal.isValid("http://1.1.1.255"));
	   System.out.println(urlVal.isValid("http://1.1.1.256"));
	   System.out.println(urlVal.isValid("http://1.1.1.999"));
	   System.out.println(urlVal.isValid("http://1.1.1.1000"));
	   System.out.println(urlVal.isValid("http://255.255.255.255"));
	   System.out.println(urlVal.isValid("http://256.255.255.255"));
	   System.out.println(urlVal.isValid("http://255.256.255.255"));
	   System.out.println(urlVal.isValid("http://255.255.256.255"));
	   System.out.println(urlVal.isValid("http://255.255.255.256"));
   }
   
   
   public void testIsValid()
   {
	   for(int i = 0;i<10000;i++)
	   {
		   
	   }
   }
   
   public void testHost()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);

	   Assert.assertTrue("http://amazon.com sould be true", urlVal.isValid("http://amazon.com"));
	   Assert.assertTrue("http://amazon.net sould be true", urlVal.isValid("http://amazon.net"));
	   Assert.assertTrue("http://amazon.io sould be true", urlVal.isValid("http://amazon.io"));
	   Assert.assertTrue("http://amazon.io sould be true", urlVal.isValid("http://amazon.io"));
   }
   
   public void testPrefix()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   Assert.assertTrue("http://amazon.io sould be true", urlVal.isValid("http://amazon.io"));
	   Assert.assertTrue("ftp://amazon.io sould be true", urlVal.isValid("ftp://amazon.io"));
	   Assert.assertTrue("telnet://amazon.io sould be true", urlVal.isValid("telnet://amazon.io"));

   }
   
   public void testPort()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);

	   for(int i = 0; i <= 65536; i++)
	   {
		   Assert.assertTrue("http://amazon.com:" + i + " failed", urlVal.isValid("http://amazon.com:" + i));
	   }
	   Assert.assertFalse("http://amazon.com:-1 should have been false but was true", urlVal.isValid("http://amazon.com:-1"));
	   Assert.assertFalse("http://amazon.com:65537 should have been false but was true", urlVal.isValid("http://amazon.com:65537"));

   }
   
   public void testExtensions()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   Assert.assertTrue(urlVal.isValid("http://amazon.com/abc123"));
	   Assert.assertFalse(urlVal.isValid("http://amazon.com/@#$%^#%^*#&!@$RT#GEAGVG#@G!#$T"));

   }
   
   public void testGetVars()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   Assert.assertTrue(urlVal.isValid("http://amazon.com/happy/?abc=123"));
	   Assert.assertTrue(urlVal.isValid("http://amazon.com/happy/?abc=123&action=view"));


   }
   
   public void testAnyOtherUnitTest()
   {
	   
   }
   /**
    * Create set of tests by taking the testUrlXXX arrays and
    * running through all possible permutations of their combinations.
    *
    * @param testObjects Used to create a url.
    */
   

}
